import React from 'react';
import G2 from '@antv/g2';
import axios from '../service';

class Count extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      data :[
       
      ]
    };
  }

  componentDidMount() {
    axios.post("/query/countsum").then((res)=>{
       this.setState({
         data:res.data
       });
       const chart = new G2.Chart({
        container: 'c1', // 指定图表容器 ID
        autoFit: true,
        width: 800, // 指定图表宽度
        height: 500 // 指定图表高度,自适应
        });
        chart.source(this.state.data);
      
        //interval创建柱形图
        chart.interval().position('genre*学生数量');
        chart.render();
    })
    
  }
  render() {
    return (
      <div id="c1" className="charts" style={{width:"800px",margin:'50px auto 0'}}>

      </div>
    );
  }

}

export default Count;